#ifndef MAPLOADER_HPP
#define MAPLOADER_HPP
// See https://github.com/bjorn/tiled/wiki/TMX-Map-Format
//   for Tmx File Format Reference documentation
#include <string>
#include <vector>
#include <tinyxml.h>
namespace Tmx
{
class Layer;
class ImageLayer;
class ObjectGroup;
class Tileset;
enum MapOrientation {
  TMX_MO_ORTHOGONAL,
  TMX_MO_ISOMETRIC,
  TMX_MO_STAGGERED};

class Map {
public:
  Map(std::string tmxFile) {
	  fileName = tmxFile;
	  mapWidth = 0;
	  mapHeight = 0;
	  tileWidth = 0;
	  tileHeight = 0;
	  orientation = TMX_MO_ORTHOGONAL;
	  Error = false;
	};
  ~Map();
  void parse();
  int getWidth() {return mapWidth;}
  int getHeight() {return mapHeight;}
  int getTileWidth() {return tileWidth;}
  int getTileHeight() {return tileHeight;}
  int getNumLayers() {return layers.size();}
  int getImageLayers() {return imageLayers.size();}
  int getNumObjectGroups() {return objectGroups.size();}
  int getNumTilesets() {return tilesets.size();}
  int FindTilesetIndex(int gid);
  Layer *getLayer(int i) {return layers.at(i);}
  ImageLayer *getImageLayer(int i) {return imageLayers.at(i);}
  ObjectGroup *getObjectGroup(int i) {return objectGroups.at(i);}
  Tileset *getTileSet(int i) {return tilesets.at(i);}
  Tileset *FindTileset(int gid);
private:
  // map information
  std::string fileName;
  Tmx::MapOrientation orientation;
  bool Error;
  int mapWidth;
  int mapHeight;
  int tileWidth;
  int tileHeight;

  std::vector<Layer*> layers;
  std::vector<ImageLayer *> imageLayers;
  std::vector<ObjectGroup*> objectGroups;
  std::vector<Tileset *> tilesets;
}; // class MapLoad

}; // namespace Tmx
#endif
